<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="../../common/layui.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
</head>
<body>
<!-- 弹出页 -->
<form class="layui-form" id="model" style="padding-top: 10px;">
    <!-- 隐藏属性 -->
    <input id="load" type="hidden" name="load" value="${load}"/>
    <input id="id" type="hidden" name="id" value="${model.id}"/>

    <!-- 流程定义ID-->
    <input id="flowDepId" type="text" name="flowDepId" value="${model.flowDepId}"/>
    <!-- 流程定义名字-->
    <input id="flowName" type="text" name="flowName" value="${model.flowName}"/>
    <!-- 单个流程ID-->
    <input id="flowId" type="text" name="flowId" value="${model.flowId}"/>
    <!-- 节点ID-->
    <input id="nodeId" type="text" name="nodeId" value="${model.nodeId}"/>

    <!-- 内容 -->
    <div class="manage_text2">

        <div class="layui-form-item manage-form-item" >
            <label class="layui-form-label manage_text_bt"><span>部门</span><i>*</i></label>
            <input class="layui-input newsName manage_text_input" id="depart" name="depart" value="${model.depart}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>开始时间</span><i>*</i></label>
            <input class="layui-input newsName manage_text_input" id="startTime" name="startTime" value="${model.startTime}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>结束时间</span><i>*</i></label>
            <input class="layui-input newsName manage_text_input" id="endTime" name="endTime" value="${model.endTime}"/>
        </div>

        <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>原因</span><i>*</i></label>
            <textarea class="layui-input newsName manage_text_input" style="height: 150px;" id="reason"  name="reason">${model.reason}</textarea>
        </div>


      <%--  <div class="layui-form-item manage-form-item">
            <label class="layui-form-label manage_text_bt"><span>其他</span></label>
            <textarea class="layui-input newsName manage_text_input" style="height: 80px;" id="other"  name="other">${model.other}</textarea>
        </div>--%>

    </div>
</form>

<script type="text/javascript">
    $(function () {
        var load = $("#load").val();
        if ("detail" == load) {//是查看
            $("input,textarea,select").attr("readonly", "readonly");
        } else {

            layui.use([ 'layer','form','laydate'], function(){
                var  layer = layui.layer , form = layui.form, laydate = layui.laydate;
                laydate.render({
                    elem: '#startTime'
                    ,range: false
                    ,type: 'datetime'
                });
                //结束时间
                laydate.render({
                    elem: '#endTime'
                    ,range: false
                    ,type: 'datetime'
                });
                form.render();//重新渲染
            });

            $("input,textarea,select").removeAttr("readonly");
        }
    });

    /**添加或者修改的方法*/
    function saveOrUpdate() {
        if (checkForm() == false) {
            return false;
        }
        var load = $("#load").val();
        var url = "";
        if(load=="add"){
            url = "flow/start";//开始任务
        }else{
            url = "flow/complete";//完成任务
        }
        var res = false;
        $.ajax({
            url: url ,
            type: "post",
            cache: false,
            async: false,
            data: $("#model").serialize(),
            dataType: "json",
            success: function (data) {
                if (data.msg == "success") {
                    parent.layer.msg('操作成功！', {icon: 1});
                    res = true;
                } else {
                    parent.layer.msg('操作失败：' + data.msg, {icon: 5});
                }
            },
            error: function (data) {
                parent.layer.msg('系统异常！', {icon: 1});
            }
        });
        return res;
    }

    function checkForm() {
       /*

         var formData = new FormData($("#stiForm" )[0]);
	            $.ajax({
	                url: auditUrl,
	                type:"post",
	                cache:false,
	                async:false,
	                processData: false,
	                contentType: false,
	                data:formData,


       var name = $("#name").val();
        var parten = /^.{1,200}$/;//标题不能超过200个字
        if (!name.match(parten)) {
            parent.layer.msg('名称不能为空');
            return false;
        }*/
        return true;
    }

</script>
</body>
</html>
